home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SOUND.SWG / 0044_SBTALKER.pas < prev    next >
Pascal/Delphi Source File  |  1994-05-25  |  5KB  |  193 lines

  1. {
  2. Sasha Case,
  3.  
  4. 12-Apr-94 20:07, Sasha Case wrote to All
  5.                Subject: SBTALKER
  6.               Terminate 1.40 REGISTERED
  7.  
  8.  
  9.  SC> @MSGID: 3:711/929@fidonet 72328398
  10.  SC> @REGEED: 1.02u2 00910093
  11.  SC> Hi Everyone,
  12.  SC> 
  13.  SC> I've tried once, a coupla months ago, but I'll try again:
  14.  SC> 
  15.  SC> I'm look for anyone with a Sound Blaster SDK or anyone who knows/has 
  16.  SC> source for 
  17.  SC> how to access SBTALKER that comes with soundblaster.  Programs like 
  18.  SC> SBTALKER 
  19.  SC> and READ do it, and I have seen source for something that did what I
  20.  SC> needed,
  21.  SC> except it used a library I haven't got.  Any help on Units that do this
  22.  SC> or
  23.  
  24. Here you go!
  25. }
  26.  
  27. Unit SBTS;
  28.  
  29. Interface
  30.  
  31. {     This unit provides an interface to the SBTALKER (TM) Text-to-Speech
  32.       driver.
  33.  
  34.       USAGE NOTES:
  35.        1.  Make sure you have made SBTALKER resident, prior to running your
  36.            application.  Call from the DOS command line:
  37.               SBTALKER /DBLASTER
  38.  
  39.            SBTALKER.EXE and BLASTER.DRV are found on the diskettes that
  40.            came with the Sound Blaster.
  41.        2.  Due to the fact that this unit relies on the built-in assembler,
  42.            you'll need Turbo Pascal, version 6.0 or later to recompile.
  43.        3.  IMPORTANT:  Don't attempt to run an application within the
  44.            Turbo Pascal Integrated Development Environment.  Do not launch
  45.            it inside a software-debugger either!  It'll HANG your system.
  46.            RUN it from the DOS command line.
  47.  
  48.        Written by Wilbert van Leijen, Amsterdam 1991.
  49.        Released with source code and all to the Public Domain on an
  50.        AS-IS basis.  The author assumes NO liability; you use this at your
  51.        risk.
  52.  
  53.        SBTALKER is a registred trade mark of First Byte, Inc. }
  54.  
  55. Type
  56.   SpeechType   = Record                { SBTALKER configuration record }
  57.                    talk,
  58.                    phoneme     : String;
  59.                    gender,
  60.                    tone,
  61.                    volume,
  62.                    pitch,
  63.                    speed       : Integer;
  64.                  end;
  65. Const
  66.   TalkerReady  : Boolean = False;      { Flag indicating SBTALKER status }
  67.  
  68. Var
  69.   TalkPtr      : Pointer;              { Pointer to the resident driver }
  70.   SpeechRec    : ^SpeechType;          { Pointer to the configuration record }
  71.  
  72. Procedure Say(talk : String);
  73. Procedure Settings(gender, tone, volume, pitch, speed : Integer);
  74. Function UnloadDriver : Boolean;
  75.  
  76. Implementation
  77.  
  78. {$R-,S- }
  79.  
  80. { Talk to me }
  81.  
  82. Procedure Say(talk : String); Assembler;
  83.  
  84. ASM
  85.         CMP    [TalkerReady], False
  86.         JE     @1
  87.         LES    DI, [SpeechRec]
  88.         PUSH   DS
  89.         LDS    SI, talk
  90.         CLD
  91.         LODSB
  92.         STOSB
  93.         XOR    CH, CH
  94.         MOV    CL, AL
  95.         REP    MOVSB
  96.         POP    DS
  97.         MOV    AL, 7
  98.         CALL   [TalkPtr]
  99. @1:
  100. end;  { Say }
  101.  
  102. { Alter the settings of the SBTALKER driver.
  103.   Gender: 0 is male, 1 is female;
  104.   Tone:   0 is bass, 1 is treble;
  105.   Volume, pitch and speed must be within the range 0..9.   }
  106.  
  107. Procedure Settings(gender, tone, volume, pitch, speed : Integer); Assembler;
  108.  
  109. ASM
  110.         CMP    [TalkerReady], False
  111.         JE     @1
  112.         LES    DI, [SpeechRec]
  113.         CLD
  114.         ADD    DI, SpeechType.gender
  115.         MOV    AX, gender
  116.         STOSW
  117.         MOV    AX, tone
  118.         STOSW
  119.         MOV    AX, volume
  120.         STOSW
  121.         MOV    AX, pitch
  122.         STOSW
  123.         MOV    AX, speed
  124.         STOSW
  125.         MOV    AL, 2
  126.         CALL   [TalkPtr]
  127. @1:
  128. end;  { Settings }
  129.  
  130. { Unload the SBTALKER driver.  Returns True is successful }
  131.  
  132. Function UnloadDriver : Boolean; Assembler;
  133.  
  134. ASM
  135.         MOV    AX, False
  136.         CMP    [TalkerReady], False
  137.         JE     @1
  138.         MOV    AX, 0FBFFh
  139.         INT    2Fh
  140. @1:
  141. end;  { UnloadDriver }
  142.  
  143. Begin  { SBTS }
  144. ASM
  145.  
  146.   { Get the vector to multiplex interrupt 2Fh.  Assume it belongs to SBTALKER }
  147.  
  148.         MOV    AX, 352Fh
  149.         INT    21h
  150.         MOV    AX, ES
  151.         OR     AX, AX
  152.         JZ     @1
  153.  
  154.   { Pass the magic number to the handler }
  155.  
  156.         MOV    AX, 0FBFBh
  157.         INT    2Fh
  158.  
  159.   { Driver responds if the return code is non zero }
  160.  
  161.         OR     AX, AX
  162.         JNE    @1
  163.  
  164.   { Retrieve the pointers to the SBTALKER driver and its configuration record }
  165.  
  166.         MOV    AX, ES:[BX+4]
  167.         MOV    DX, ES:[BX+6]
  168.         MOV    Word Ptr [TalkPtr], AX
  169.         MOV    Word Ptr [TalkPtr+2], DX
  170.         ADD    BX, 20h
  171.         MOV    Word Ptr [SpeechRec], BX
  172.         MOV    Word Ptr [SpeechRec+2], DX
  173.  
  174.   { Put the default values for gender, tone etc. into this record }
  175.  
  176.         LES    DI, [SpeechRec]
  177.         ADD    DI, SpeechType.gender
  178.         CLD
  179.         SUB    AX, AX
  180.         STOSW                          { gender = male }
  181.         STOSW                          { tone   = bass }
  182.         MOV    AX, 5
  183.         STOSW                          { volume = 5 }
  184.         STOSW                          { pitch  = 5 }
  185.         STOSW                          { speed  = 5 }
  186.         MOV    AL, 2
  187.         CALL   [TalkPtr]
  188.         MOV    [TalkerReady], True
  189. @1:
  190. end;
  191. end.  { SBTS }
  192.  
  193.